﻿@model SchoolCommunicationSystem.Models.ViewGradesByClassModels

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_TeacherLayout.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
@Scripts.Render("~/bundles/tablesorter")
@Scripts.Render("~/bundles/tablesorterpaging")
<div id="page-heading">
    <h1>Tình Trạng Học Tập</h1>
</div>
<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4>Điểm theo lớp</h4>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        @Html.Label("Năm học:", new { @class = "col-sm-2" })
                        @Html.Label("Học kỳ", new { @class = "col-sm-2" })

                        @Html.Label("Lớp học", new { @class = "col-sm-2" })

                        @Html.Label("Môn học", new { @class = "col-sm-6" })

                    </div>
                    <div class="form-group">
                        @Html.Partial("~/Views/ViewGradesByClass/_SchoolYear.cshtml")
                        <div id="term">
                            @Html.Partial("~/Views/ViewGradesByClass/_Term.cshtml")
                        </div>
                        <div id="subject">
                            @Html.Partial("~/Views/ViewGradesByClass/_Subject.cshtml")
                        </div>
                    </div>
                    <div id="result" style="padding-top:10px; border-top:1px solid black;margin-top: 7%;">
                        @Html.Partial("~/Views/ViewGradesByClass/_Result.cshtml")
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        //Hide the submit buttons. If javascript is disabled we'll use the normal functionality
        $('input[type=submit]').hide();

        //SchoolYear select
        $('#SchoolYear').change(function () {
            $(this).parents('form').submit();
            return false;
        });

        //SchoolYear form submit
        $("form[action$='SelectSchoolYear']").submit(function () {
            $.ajax({
                url: $(this).attr('action'),
                type: 'post',
                data: $(this).serialize(),
                success: function (result) {
                    $('#term').html(result);
                    $('input[type=submit]').hide();
                }
            });
            return false;
        });

        //ClassInSchoolYear select
        $('#ClassInSchoolYear').live('change', function () {
            $(this).parents('form').submit();
            return false;
        });

        //ClassInSchoolYear form submit
        $("form[action$='SelectClass']").live('submit', function () {
            $.ajax({
                url: $(this).attr('action'),
                type: 'post',
                data: $(this).serialize(),
                success: function (result) {
                    $('#subject').html(result);
                    $('input[type=submit]').hide();
                }
            });
            return false;
        });

        //Subject select
        $('#Subject').live('change', function () {
            $(this).parents('form').submit();
            return false;
        });

        $("form[action$='ViewGradesByClass']").live('submit', function () {
            $.ajax({
                url: $(this).attr('action'),
                type: 'post',
                data: $(this).serialize(),
                success: function (result) {
                    $('#result').html(result);
                    $('input[type=submit]').hide();
                }
            });
            return false;
        });
    });

</script>
